﻿using System;
using Telerik.Web.UI;
using Thuoc24h.Business;
using Thuoc24h.Common;

namespace Thuoc24h.AdminCP.Pages
{
    public partial class ProductView : BasePage.BasePages
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                //  GetData();

            }
        }



        protected void gridData_ItemCommand(object sender, GridCommandEventArgs e)
        {
            string id = string.Empty;

            var commandName = e.CommandName;
            var gridDataItem = e.Item as GridDataItem;
            if (gridDataItem != null)
            {
                id = gridDataItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString();
            }

            switch (commandName)
            {
                case CommandNames.Edit:
                    Utils.Redirect(UrlManager.Admin.ProductEdit, id);
                    break;
                case CommandNames.Delete:
                    ReviewRepository.ProductDelete(id.ToInt32Return0());

                    break;
                case "InitInsert":
                    Utils.Redirect(UrlManager.Admin.ProductEdit);
                    break;
            }


        }

        
    }
}